package Exercise;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise06 {
    public static void main(String[] args) throws Exception{
        Class<?> fileClass = Class.forName("java.io.File");
        Constructor<?> declaredConstructors[] = fileClass.getDeclaredConstructors();
        for (Constructor<?> declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }

        Constructor<?> declaredConstructor = fileClass.getDeclaredConstructor(String.class);
        String filePath = "e:\\mynew.txt";
        Object file = declaredConstructor.newInstance(filePath);

        Method createNewFile = fileClass.getDeclaredMethod("createNewFile");
        createNewFile.invoke(file);
    }
}